package com.swgk.core.util;

import android.text.TextUtils;

import com.swgk.core.util.PickSelectEntity;

import java.io.Serializable;
import java.util.List;

public class PickSelectTextEntity<T> implements Serializable {

    private int sort;
    private String typeName;
    private List<PickSelectEntity> pickSelectEntityList;

    private int selectedPos;

    public PickSelectTextEntity(int sort, String typeName, List<PickSelectEntity> pickSelectEntityList) {
        this.sort = sort;
        this.typeName = typeName;
        this.pickSelectEntityList = pickSelectEntityList;
    }

    public int getSort() {
        return sort;
    }

    public void setSort(int sort) {
        this.sort = sort;
    }

    public String getTypeName() {
        return typeName;
    }

    public void setTypeName(String typeName) {
        this.typeName = typeName;
    }

    public List<PickSelectEntity> getPickSelectEntityList() {
        return pickSelectEntityList;
    }

    public void setPickSelectEntityList(List<PickSelectEntity> pickSelectEntityList) {
        this.pickSelectEntityList = pickSelectEntityList;
    }

    public void setSelectedPos(int selectedPos) {
        this.selectedPos = selectedPos;
    }

    public int getSelectedPos() {
        return selectedPos;
    }

    public String getItemNo(int position) {
        if (getPickSelectEntityList() == null || getPickSelectEntityList().size() == 0) {
            return "";
        }
        String pickerViewText = getPickSelectEntityList().get(position).getPickerViewText();
        if (TextUtils.equals("全部", pickerViewText) || TextUtils.equals("不限", pickerViewText)|| TextUtils.equals("全国", pickerViewText) ) {
            return "";
        }
        return getPickSelectEntityList().get(position).getNo();
    }

    public String getItemName(int position) {
        if (getPickSelectEntityList() == null || getPickSelectEntityList().size() == 0) {
            return getTypeName();
        }
        String pickerViewText = getPickSelectEntityList().get(position).getPickerViewText();
        if (TextUtils.equals("全部", pickerViewText) || TextUtils.equals("不限", pickerViewText) || TextUtils.equals("全国", pickerViewText)) {
            return getTypeName();
        }
        return getPickSelectEntityList().get(position).getPickerViewText();
    }

    @Override
    public String toString() {
        return "PickSelectTextEntity{" +
                "sort=" + sort +
                ", typeName='" + typeName + '\'' +
                ", pickSelectEntityList=" + pickSelectEntityList +
                '}';
    }
}
